import { createStore } from 'vuex'
import menu from './module/menu'
const store = createStore({
  state: {
    globalLoading: 0,
    userInfo: '',
    buyStatus: false,
    // 1:关闭
    hasNativeBack: 0
  },
  modules: {
    menu
  },
  mutations: {
    setUserInfo(state, val) {
      state.userInfo = val
    },
    changeLoading(state, val) {
      let total = state.globalLoading + val
      total = total < 0 ? 0 : total
      state.globalLoading = total
    },
    changeBuyStatus(state, val) {
      state.buyStatus = val
    },
    changeNativeBack(state, val = 0) {
      state.hasNativeBack = val
    }
  }
})
export default store
